package com.gxa.insurance.service.impl;

import com.gxa.insurance.exception.BusinessException;
import com.gxa.insurance.exception.ExceptionCode;
import com.gxa.insurance.mapper.VarietyMapper;
import com.gxa.insurance.pojo.Variety;
import com.gxa.insurance.service.VarietyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @date 2022/6/9
 */
@Service("varietyService")
@Transactional(rollbackFor = {Throwable.class})
public class VarietyServiceImpl implements VarietyService {

    @Autowired
    VarietyMapper varietyMapper;

    @Override
    public List<Variety> selectByName(String name) throws BusinessException {

        List<Variety> varieties = varietyMapper.selectByName(name);
        if (varieties.size()==0){
            throw new BusinessException(ExceptionCode.USER_NOT_FONUD);
        }
        return varieties;
    }
}
